package com.supermap.business.newmessage;

import com.alibaba.dubbo.config.annotation.Reference;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.newmessage.NewmessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lxs
 * @Title:最新评论访问层
 * @Description:
 * @date 2018/3/14  14:28
 */
@Controller
@RequestMapping("NewMessageController")
public class NewMessageController {
    /**
     * 使用指定类初始化日志对象，在日志输出的时候，可以打印出日志信息所在类
     */
    protected static final Logger logger = LoggerFactory.getLogger(NewMessageController.class);
    @Reference
    private NewmessageService newmessageService;

    /**
     * 得到全部最新的评论
     * @return
     */
    @RequestMapping("/getNewMessageList")
    @ResponseBody
    public JSONUtil getNewMessageList(HttpServletRequest request){
        String uid=request.getParameter("uid");
        return newmessageService.getNewMessageList(uid);
    }

    /**
     * 根据ID 修改其状态
     * @param request
     * @return
     */
    @RequestMapping("/updateNewMessage")
    @ResponseBody
    public JSONUtil updateNewMessage(HttpServletRequest request){
        String id=request.getParameter("id");
        return newmessageService.updateNewMessage(id);
    }

    /**
     * 根据ID 修改其状态 并查出起对象
     * @param request
     * @return
     */
    @RequestMapping("/getNewMessageandUpdateById")
    @ResponseBody
    public JSONUtil getNewMessageandUpdateById(HttpServletRequest request){
        String id=request.getParameter("id");
        return newmessageService.getNewMessageandUpdateById(id);
    }
}
